﻿using JESAI.Core.Attributes;
using JESAI.Platform.Domain.Admin.Repositories;
using Sys.Workflow.Engine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JESAI.Application.Service.Workflow
{
    [AppService]
    public class UserGroupLookupProxy : IUserGroupLookupProxy
    {

        private readonly IRoleRepository _roleRepository;
        private readonly IUserRoleRepository _userRoleRepository;
        public UserGroupLookupProxy(IRoleRepository roleRepository, IUserRoleRepository userRoleRepository)
        {
            _roleRepository = roleRepository;
            _userRoleRepository = userRoleRepository;
        }

        public IList<string> GetGroupsForCandidateUser(string candidateUser)
        {
            IList<string> roles = _userRoleRepository._DbQueryable.Where(p => p.Uid == long.Parse(candidateUser)).Select(p => p.RoleId.ToString()).ToList();
            return roles;
        }
    }
}
